//
//  AccountController.m
//  QRBuildScan
//
//  Created by gongjie on 12-1-3.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "AccountController.h"

@implementation AccountController
@synthesize a_rightbuttn;


//- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
//{
//    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
//    if (self) {
//        // Custom initialization
//    }
//    return self;
//}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView
{
}
*/


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
    [self.view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"background.png"]]];
    a_Tableview = [[UITableView alloc] initWithFrame:CGRectMake(10, 10,300 ,150 ) style:UITableViewStyleGrouped];
    [a_Tableview setBackgroundColor:[UIColor clearColor]];
    [a_Tableview setDelegate:self];
    [a_Tableview setDataSource:self];
    [self.view addSubview:a_Tableview];
    a_rightbuttn= [UIButton buttonWithType:UIButtonTypeCustom];
    a_rightbuttn.frame = CGRectMake(250,7, 60, 30);
    [a_rightbuttn setBackgroundImage:[UIImage imageNamed:@"open.png"] forState:UIControlStateNormal];
    [a_rightbuttn addTarget:self action:@selector(changOpen) forControlEvents:UIControlEventTouchUpInside];
    
//    r_leftbuttn = [UIButton buttonWithType:UIButtonTypeCustom];
//    r_leftbuttn.frame = CGRectMake(10,7, 60, 30);
//    [r_leftbuttn setBackgroundImage:[UIImage imageNamed:@"cancel.png"] forState:UIControlStateNormal];
//    [r_leftbuttn addTarget:self action:@selector(changRleft) forControlEvents:UIControlEventTouchUpInside];
}
-(void)changOpen
{
    if (a_rightbuttn.superview) {
        [a_rightbuttn removeFromSuperview];
    }
    [self.navigationController popViewControllerAnimated:YES];
}
#pragma mark UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 2;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UIView* tview = [[[UIView alloc] initWithFrame:tableView.frame] autorelease];
	[tview setBackgroundColor:[UIColor clearColor]];
	[tableView setBackgroundView:tview];
    static NSString *CellIdentifier = @"Cell";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
        cell.selectionStyle =UITableViewCellSelectionStyleNone;
        
        UILabel* tip1 = [[UILabel alloc] initWithFrame:CGRectMake(20, 15, 50, 20)];
        tip1.tag = 1;
        [tip1 setBackgroundColor:[UIColor clearColor]];
        tip1.font = [UIFont systemFontOfSize:18];
        tip1.textColor = [UIColor blackColor];
        [cell.contentView addSubview:tip1];
        
        UILabel* tip2 = [[UILabel alloc] initWithFrame:CGRectMake(70, 15, 200, 20)];
        tip2.tag = 2;
        [tip2 setBackgroundColor:[UIColor clearColor]];
        tip2.font = [UIFont systemFontOfSize:18];
        tip2.textColor = [UIColor blackColor];
        [cell.contentView addSubview:tip2];
    }
    UILabel* ilabel = (UILabel*)[cell.contentView viewWithTag:1];
    UILabel* ilabel1 = (UILabel*)[cell.contentView viewWithTag:2];
    if ([indexPath row] == 0) {
        [ilabel setText:@"帐户:"];
        [ilabel1 setText:@"zlgj9182@hotmail.com"];
    }
    else
    {
        [ilabel setText:@"姓名:"];
       [ilabel1 setText:@"gongjie"];
    }
    
    return cell;
}

#pragma mark UITableViewDelegate
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 50;
}
- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

-(void)dealloc
{
   [a_Tableview release];
    a_rightbuttn = nil;
    [super dealloc];
}
@end
